package com.cg.system.util;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by SimonZou on 16/4/13.
 */
public class ResourceUtil {
    public static String getRequestPath(HttpServletRequest request) {
//        admin/index.do;jsessionid=28E735772ED1C76778BCC75F4454E03A?null
        String requestPath = request.getRequestURI();
        if(requestPath.indexOf(";jsessionid")>-1){//去掉;jsessionid=28E735772ED1C76778BCC75F4454E03A
            requestPath = requestPath.substring(0, requestPath.indexOf(";jsessionid"));
        }
        if(request.getQueryString()!=null){
            requestPath = requestPath+"?" + request.getQueryString();
        }


        if (requestPath.indexOf("&") > -1) {// 去掉其他参数
            requestPath = requestPath.substring(0, requestPath.indexOf("&"));
        }
        requestPath = requestPath.substring(request.getContextPath().length() + 1);// 去掉项目路径
        return requestPath;
    }
}
